<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./font/iconfont.js"></script>
    <link rel="stylesheet" href="./css/hot list.css">
</head>
<body>
    <header>
        <nav id="cnav">
            <ul>
                <li>
                    <a href="#">
                        <svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-shoucang"></use>
                        </svg>
                    </a>
                </li>
        
                <li>
                    <a href="./thought.html">
                        
                            <p>
                                想法
                            </p>
                        
                    </a>
                </li>
                <li>
                    <a href="./home page.html">
                        
                            <p>推荐</p>
                       
                    </a>
                </li>
                <li>
                    <a href="./hot list.html">
                        
                            <p>
                                热榜
                            </p>
                        
                    </a>
                </li>
                <li>
                    <a href="#">
                        <svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-lingdang"></use>
                        </svg>
                    </a>
                </li>
            </ul>
        </nav>
    </header>
    <div class="update"><a href="#">
        <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-zhibo"></use>
        </svg>
    </a>直播 北京召开疫情发布会</div>
    <div id="main">
        <ul class="search">
        </ul>
    </div>
    <!-- ***************************JavaScript**************************** -->
    <script>


        var url = "http://rap2api.taobao.org/app/mock/308020/0810"
        var xhr = new XMLHttpRequest();

        xhr.open("GET", url, true);//get请求，url说明是yrl,true是异步
        xhr.send();

        xhr.onreadystatechange = function () {//监听成功
            if (xhr.readyState === 4 && xhr.status === 200) {//状态码为200
                console.log(xhr.responseText);
                var jarr = JSON.parse(xhr.responseText);
                //从服务器端获得数据在网页显示 JSON.parse()服务器端数据变成json
                insert(jarr);//insert这个名字是自己起名的
            }
        }
        function insert(jarr) {
            var alist = document.querySelector(".search");//获取上面的class
            jarr.forEach((v, i) => {
                var nli = document.createElement("li");//创建一个元素
                nli.innerHTML = `
            <li>
                <dev class="number">${v.number}</dev>
                <a href="${v.link}">${v.title}</a>
            </li>
            <li class="henxian"></li>`;
                alist.appendChild(nli);//末尾加一个li
            });
        }
    </script>


 
    
    <footer>
        <div id="bnav">
           
                <ul>
                    <li>
                        
                        <a href="./home page.html">
                            <div>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-shouye2"></use>
                                </svg>
                            </div>
                            <p>首页</p>
                        </a>
                    </li>
                    <li>
                        
                        <a href="./attention.html">
                            <div>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-guanzhu"></use>
                                </svg>
                            </div>
                            <p>关注</p>
                        </a>
                    </li>
                    <li>
                        
                        <a href="#">
                            <div>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tianjia"></use>
                                </svg>
                            </div>
                           
                        </a>
                    </li>
                    <li>
                        
                        <a href="#">
                            <div>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-a-huiyuanVIP"></use>
                                </svg>
                            </div>
                            <p>会员</p>
                        </a>
                    </li>
                    <li>
                        
                        <a href="./my.html">
                            <div>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-wode1"></use>
                                </svg>
                            </div>
                            <p>我的</p>
                        </a>
                    </li>
                </ul>
              
            </nav>
                </footer>
                
                
    </body>
    
</body>
</html>